<template>
  <div class="login_container">
   <div class="img1">
     <div class="img2"></div>
     <div class="img3"></div>
     <div class="img4"></div>
   </div>
    <div class="box">
      <div class="box-one">
        <img src="../../assets/use_image.png" alt="" />
        <p>众投招标系统</p>
      </div>

      <el-form ref="loginFormRef" :model="loginForm" :rules="rules" class="login_form">
        <el-form-item prop="username">
          <el-input v-model="loginForm.username" prefix-icon="el-icon-user-solid"></el-input>
        </el-form-item>
        <el-form-item prop="password">
          <el-input v-model="loginForm.password" prefix-icon="el-icon-key" show-password></el-input>
        </el-form-item>
        <el-form-item class="btns">
          <el-button type="primary" @click="resetLoginform" class="sign">登录</el-button>
          <!-- <el-button type="info" @click="resetLoginForm">重置</el-button> -->
        </el-form-item>
      </el-form>
    </div>
  </div>
</template>

<script>
export default {
  data() {
    return {
      loginForm: {
        username: 'admin',
        password: '123456',
      },
      rules: {
        username: [
          { required: true, message: '请输入用户名', trigger: 'blur' },
          { min: 3, max: 10, message: '长度在 3 到 10 个字符', trigger: 'blur' },
        ],
        password: [
          { required: true, message: '请输入用户密码', trigger: 'blur' },
          { min: 6, max: 15, message: '长度在 6 到 15 个字符', trigger: 'blur' },
        ],
      },
    }
  },
  methods: {
    resetLoginform() {
      if (this.loginForm.username === 'admin' && this.loginForm.password === '123456') {
        this.$store.dispatch('user/login', this.loginForm).then(() => {
            this.$router.push({ path: this.redirect || '/' })
            this.loading = false
          }).catch(() => {
            this.loading = false
          })
        } else {
          console.log('error submit!!')
          return false
        }
    },
    // resetLoginForm() {
    //   this.$refs.loginFormRef.resetFields()
    // },
  },
}
</script>

<style scoped>
.login_container {
  overflow: hidden;
  height: 100%;
}
.login_container img {
  overflow: hidden;
}
.img1{
  position: relative;
  width: 100%;
  height: 100%;
  background:url(../../assets/bg.jpg)no-repeat top center;
  background-size: 100% 100%;
}
.img2{
  position: absolute;
  top:50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 518px;
  height: 518px;
  background: url(../../assets/map.png)no-repeat;
}
.img3{
  position: absolute;
  top:50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width:643px;
  height: 643px;
  background: url(../../assets/lbx.png)no-repeat;
  animation: rotate1 15s linear infinite;
  opacity: 0.6;
}
.img4{
  position: absolute;
  top:50%;
  left: 50%;
  transform: translate(-50%,-50%);
  width: 566px;
  height: 566px;
  background: url(../../assets/jt.png)no-repeat;
  animation: rotate2 10s linear infinite;
  opacity: 0.6;
}
/* 动画 */
@keyframes rotate1 {
  form {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(360deg);
  }
}
@keyframes rotate2 {
  form {
    transform: translate(-50%, -50%) rotate(0deg);
  }
  to {
    transform: translate(-50%, -50%) rotate(-360deg);
  }
}
.images {
  width: 100%;
  height: 100%;
}
.box {
  width: 450px;
  height: 300px;
  background-color: #010F4C;
  border-radius: 32px;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%,-50%);
}
.box-one {
  width: 130px;
  height: 130px;
  border: 1px solid #ccc;
  border-radius: 50%;
  position: absolute;
  top: 0;
  left: 50%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 15px #ddd;
}
.box-one img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  background-color: #eee;
}
.box-one p {
  display: block;
  width: 350px;
  color:orange;
  font-size: 18px;
}
.login_form {
  position: absolute;
  bottom: 0;
  width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
}
.btns {
  display: flex;
  justify-content: flex-end;
}
.sign{
  width: 410px !important;
}
</style>
